﻿Imports System.Data.OleDb
Public Class showbookclubprofile
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            join.Visible = True
            success.Visible = False
        End If
        If IsPostBack Then
            success.Visible = True
            join.Visible = False
            Return
        End If
        displayData()
    End Sub
    Protected Sub displayData()
        Dim conn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
        conn.Open()
        Dim cmd As New OleDbCommand("SELECT * FROM bookclubs WHERE (ID = ?) ", conn)
        cmd.Parameters.AddWithValue("@f1", Request.Params("ID"))
        UserProfileInfo.DataSource = cmd.ExecuteReader()
        UserProfileInfo.DataBind()
        conn.Close()

    End Sub
    Protected Sub displayMemberships()
        Dim conn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
        conn.Open()
        Dim cmd As New OleDbCommand("SELECT * FROM clubuserjunction WHERE (BookClubID = ?) ", conn)
        cmd.Parameters.AddWithValue("@f1", Request.Params("ID"))
        bookClubMembers.DataSource = cmd.ExecuteReader()
        bookClubMembers.DataBind()
        conn.Close()
    End Sub
    Protected Sub btnJoinClub()
        Dim conn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("BookMeetConnString").ConnectionString)
        conn.Open()
        Dim cmdshelf As New OleDbCommand("INSERT INTO clubuserjunction (UserName,BookClubID) VALUES(@f1,@f2) ", conn)
        cmdshelf.Parameters.AddWithValue("@f1", User.Identity.Name)
        cmdshelf.Parameters.AddWithValue("@f2", Request.Params("ID"))
        cmdshelf.ExecuteNonQuery()
        conn.Close()
        displayData()
    End Sub
End Class